home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0015 / flicker / polar.asm < prev    next >
Assembly Source File  |  1997-04-16  |  1KB  |  80 lines

  1.  
  2.     public _sin_tab
  3.  
  4.  
  5.  
  6.     ;    polar(theta, rad, xybuf)
  7.     ;        returns cartesian equivalent to theta, rad in xybuf    
  8.     public _polar
  9.  
  10. _polar
  11.     move.w    4(sp),d0
  12.     and.w    #$3ff,d0    ; mod theta by two-pi = 1024
  13.     move.l    #_sin_tab,a0    ; load up sine table
  14.  
  15.     move.l    #quadtable,a1    ; and jump to routine to get sine, cos for quadrant
  16.     move.w    d0,d1
  17.     and.w    #$300,d1
  18.     lsr.w    #6,d1
  19.     move.l    0(a1,d1.w),a1
  20.     jsr        (a1)
  21.  
  22.     muls    6(sp),d0
  23.     asl.l #2,d0
  24.     swap d0 
  25.     muls    6(sp),d1
  26.     asl.l #2,d1
  27.     swap d1 
  28.     move.l    8(sp),a0
  29.     move.w    d1,(a0)+
  30.     move.w    d0,(a0)
  31.     rts
  32.  
  33. quad1
  34.     move.w    #256,d1
  35.     sub.w    d0,d1
  36.     asl.w    #1,d1
  37.     move.w    0(a0,d1.w),d1    ;got cosine
  38.     asl.w    #1,d0
  39.     move.w    0(a0,d0.w),d0    ;got sine
  40.     rts
  41.  
  42. quad2
  43.     move.w    d0,d1
  44.     neg.w    d0
  45.     add.w    #512,d0
  46.     asl.w    #1,d0
  47.     move.w    0(a0,d0.w),d0    ;got sine
  48.     sub.w    #256,d1
  49.     asl.w    #1,d1
  50.     move.w    0(a0,d1.w),d1    
  51.     neg.w    d1    ; got cosine
  52.     rts
  53.  
  54. quad3
  55.     move.w #3*256,d1
  56.     sub.w    d0,d1
  57.     asl.w    #1,d1
  58.     move.w    0(a0,d1.w),d1    
  59.     neg.w    d1    ; got cosine
  60.     sub.w    #512,d0
  61.     asl.w    #1,d0
  62.     move.w    0(a0,d0.w),d0    
  63.     neg.w    d0    ; got sine
  64.     rts
  65.  
  66. quad4
  67.     move.w    d0,d1
  68.     sub.w    #3*256,d1
  69.     asl.w    #1,d1
  70.     move.w    0(a0,d1.w),d1    ; got cosine
  71.     neg.w    d0
  72.     add.w    #1024,d0
  73.     asl.w    #1,d0
  74.     move.w    0(a0,d0.w),d0
  75.     neg.w    d0    ;got sine
  76.     rts
  77.  
  78.     dseg
  79. quadtable    dc.l    quad1,quad2,quad3,quad4
  80.